/*提示语*/
var prompts = [
    ["请输入手机号或用户名","请输入正确的手机号或用户名"],//0
    ["请输入手机号","请输入正确的手机号"],//1
    ["请输入密码","请输入6-32位由数字和字母组成的密码"],//2
    ["请输入姓名","请输入正确的姓名"],//3
    ["请输入服务商名称","请输入正确的服务商名称"],//4
    ["请输入验证码","请输入正确的验证码"],//5
    ["请输入推荐码","请输入正确的推荐码"],//6
    ["请输入原密码","请输入正确的原密码"],//7
    ["请输入持卡人姓名","请输入正确的持卡人姓名"],//8
    ["请输入邮箱","请输入正确的邮箱"],//9
    ["请输入姓名","请输入正确的姓名"],//10
    ["请输入银行卡号","请输入正确银行卡号"],//11
    ["请输入收款人","请输入正确收款人"],//12
    ["请输入收款银行","请输入正确收款银行"],//13
    ["请输入开户行名称","请输入正确开户行名称"],//14
    ["请输入公司名称","请输入正确的公司名称"],//15
    ["请输入公司电话","请输入正确的公司电话"],//16
    ["请输入办公地址","请输入正确的办公地址"],//17
    ["请输入身份标签","请输入正确的身份标签"],//18
    ["请输入","请输入"],//19
    ["请输入提现金额","请输入不小于100的数字"],//20
    ["请输入身份证号","请输入正确的身份证号"],//21
    ["请输入注册地址","请输入正确的注册地址"],//22
    ["请输入行业经验","请输入正确的行业经验"],//23
    ["请输入密码","请输入6位数字密码"],//24
    ["请输入发布项目详情地址","请输入正确的发布项目详情地址"],//25
    ["请输入发布项目名称","请输入正确的发布项目名称"],//26
    ["请输入发布项目售价","请输入正确的发布项目售价"],//27
    ["请输入面积","请输入正确的面积"],//28
    ["请输入项目介绍","项目介绍不得少于2个字"],//29
    ["请输入经营范围","经营范围不得少于2个字"],//30
    ["请输入社会信用代码","请输入正确的信用代码"],//31
    ["请输入注册资本","请输入正确的注册资本"],//32
    ["请输入写字楼地址","请输入正确的写字楼地址"],//33
    ["请输入写字楼名称","请输入正确的写字楼名称"],//34
    ["请输入开发商","请输入正确的开发商"],//35
    ["请输入物业","请输入正确的物业"],//36
    ["请输入写字楼租金","请输入正确的写字楼租金"],//37
    ["请输入待出租房源（个）","请输入整数"],//38
    ["请输入已出租房源（个）","请输入整数"],//39
    ["请输入总楼层数（层）","请输入整数"],//40
    ["请输入客梯数（个）","请输入整数"],//41
    ["请输入写字楼介绍","写字楼介绍不得低于2个字"],//42
    ["请输入用户名","请输入正确的用户名"],//43

]
flag = false;
var arr = [];
var count = 0;
/*正则表达式开始*/
var reg_username = /(^[A-Za-z0-9]{3,15}$)/;//用户名
var reg_pwd = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,32}$/;//登录密码
var reg_phone_number = /^((13[0-9])|(14[7,9])|(15[^4,\D])|(17[^4,^9,\D])|(18[0-9]))\d{8}$/;//手机号
var reg_code = /^\d{4}$/;//验证码
var reg_pay_pwd = /^\d{6}$/;//支付密码、推荐码
var reg_email_number = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
var reg_service_name = /^[\u4E00-\u9FA5A-Za-z\d]{2,20}$/;//服务商名称
var reg_full_name = /^[\u4E00-\u9FA5（）()]{2,30}$/;//姓名、收款人
var reg_id_tag = /(^[A-Za-z0-9]{1,11}$)/;//身份标签
var reg_collection_account = /^\d{14,21}$/;//收款账号
var reg_receiving_bank = /^[\u4E00-\u9FA5]{4,25}$/;//收款银行
var reg_opening_bank = /^[\u4E00-\u9FA5]{2,50}$/;//开户行名称
var reg_corporate_name = /^[^\n\r]{2,50}$/;//公司名称、办公地址、注册地址、项目地址、项目名称，写字楼地址，写字楼名称，开发商，物业，写字楼介绍
//var reg_corporate_number = /^(0\d{2}\d{8})|(0\d{3}\d{7})$|^400\d{7,8}$/;//公司电话
var reg_corporate_number = /^\d{11}$/;//公司电话
var reg_withdrawal = /(^([1-9]\d{2,})$)/ ;//提现金额；，面积，
var reg_square =/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;//发布项目金额，面积，写字楼租金
var reg_id_number = /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/ ;//身份证号；
var reg_all = /./
var reg_year = /(^[1-9][0-9]{0,1}$)/;//行业经验
var reg_project_introduce = /^[^\n\r]{2,50}$/;//发布项目介绍，经营范围
var reg_social_code=/[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}/; //社会信用代码
var reg_rent_housing=/^\d+$/;  //待出租房源，已出租房源（套）
/*正则表达式结束*/
/*提交表单或input失去光标时触发的事件*/
function validate(mobile,values,myreg) {
    var mobile_wrap = mobile;
    var mobile = mobile.val();
    var mobile_id = mobile_wrap.attr("id");
    /*提示框的样式开始*/
    if(mobile_id == "confirm_pwd")  {
    }else {
        /*设置密码外的其他页面*/
        if(mobile.length==0){
            //mobile_wrap.focus()
            return values[0];
        }

        if(!myreg.test(mobile)){
            return values[1];
        }else {
            return 'ok';
        }
    }
    /*提示框的样式结束*/
}
var countdown=60;
/*获取验证码*/
function settime(obj) { //发送验证码倒计时
    if (countdown == 0) {
        obj.attr('disabled',false);
        //obj.removeattr("disabled");
        obj.val("获取验证码").css({"background-color": "#22A0DB"});
        countdown = 60;
        return;
    } else {
        obj.attr('disabled',true);
        obj.val("重新发送(" + countdown + ")").css({"background-color": "#888"});
        countdown--;
    }
    setTimeout(function() {
            settime(obj) }
        ,1000)
}

function searchSub(){
    var inputList = $("#form1 input");
    var  result;
    inputList.each(function(index)             {
        result =  'ok';
        //手机号
        if($(this).attr('id')  =='phone_number' ){
            result =   validate($("#phone_number"),prompts[1],reg_phone_number);
        }
        //收款银行
        if($(this).attr('id')  =='receiving_bank' ){
            result =   validate($("#receiving_bank"),prompts[13],reg_receiving_bank);
        }
        //行业经验
        if($(this).attr('id')  =='year' ){
            result =   validate($("#year"),prompts[23],reg_year);
        }
        //身份标签
        if($(this).attr('id')  =='id_tag' ){
            result =   validate($("#id_tag"),prompts[18],reg_id_tag);
        }
        //服务商名字
        if($(this).attr('id')  =='service_name' ){
            result =   validate($("#service_name"),prompts[4],reg_service_name);
        }
        //身份证号
        if($(this).attr('id')  =='id_number' ){
            result =   validate($("#id_number"),prompts[21],reg_id_number);
        }
        //验证码
        if($(this).attr('id')  =='code' ){
            result = validate($("#code"),prompts[5],reg_code);
        }
        //邮箱号
        if($(this).attr('id')  =='email_number' ){
            result =   validate($("#email_number"),prompts[9],reg_email_number);
        }
        //密码
        if($(this).attr('id')  =='pwd' ){
            result =   validate($("#pwd"),prompts[2],reg_pwd);
        }
        //确认密码
        if($(this).attr('id')  =='confirm_pwd' ){
            var pwd = $("#pwd").val();
            var confirm_pwd = $("#confirm_pwd").val();
            if(confirm_pwd != pwd){
                result =  "两次密码不一致";
            }else {
                result = 'ok';
            }
        }
        //持卡人姓名
        if($(this).attr('id')  =='user' ){
            result =   validate($("#user"),prompts[8],reg_full_name);
        }
        //银行卡号
        if($(this).attr('id')  =='collection_account' ){
            result =   validate($("#collection_account"),prompts[11],reg_collection_account);
        }
        //开户行
        if($(this).attr('id')  =='opening_bank' ){
            result =   validate($("#opening_bank"),prompts[14],reg_opening_bank);
        }
        //手机号或用户名
        if($(this).attr('id')  =='user_name' ){
            result =   validate($("#user_name"),prompts[0],reg_username);
        }
        //用户名
        if($(this).attr('id')  =='user_name_a' ){
            result =   validate($("#user_name_a"),prompts[43],reg_username);
        }
        //姓名
        if($(this).attr('id')  =='real_name' ){
            result =   validate($("#real_name"),prompts[3],reg_full_name);
        }
        //公司名称
        if($(this).attr('id')  =='corporate_name' ){
            result =   validate($("#corporate_name"),prompts[15],reg_corporate_name);
        }
        //公司电话
        if($(this).attr('id')  =='corporate_number' ){
            result =   validate($("#corporate_number"),prompts[16],reg_corporate_number);
        }
        //办公地址
        if($(this).attr('id')  =='office_address' ){
            result =   validate($("#office_address"),prompts[17],reg_corporate_name);
        }
        //注册地址
        if($(this).attr('id')  =='register_address' ){
            result =   validate($("#register_address"),prompts[22],reg_corporate_name);
        }
        if(result != 'ok'){
            return false
        }
    });
    return  result;
}









